package com.mdd.common.mapper.system;

import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.system.SystemAuthMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 系统菜单Mapper
 */
@Mapper
public interface SystemAuthMenuMapper extends IBaseMapper<SystemAuthMenu> {
    @Select("SELECT id FROM la_system_auth_menu WHERE MENU_NAME ='权限管理'")
    Integer getPermissionMenuId();


    @Delete("delete from la_system_auth_menu where menu_name like '%API:%'")
    void deleteMenuApiInfo();

    @Delete("delete from la_system_auth_perm where menu_id in (select id from la_system_auth_menu where menu_name like '%API:%')")
    void deleteMenuApiPermissionInfo();


    @Select("select DISTINCT au.pid from la_system_auth_menu au  where au.menu_name like '%API:%'")
    Integer getMenuApiId();

    @Select("select au.pid from la_system_auth_perm  a left join la_system_auth_menu au on a.menu_id=au.id  where a.role_id = #{roleId} and au.pid =#{pid} and au.menu_name  not like '%API:%'")
    Integer getOnleHasApiId(@Param("roleId")Integer roleId,@Param("pid")Integer pid);
}
